package cn.zh.npro.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import cn.zh.npro.Item.HgItem;
import cn.zh.npro.R;

/**
 * Created by WYN on 2018/3/2 0002.
 */

public class HgAdapter extends BaseAdapter {
    Context context;
    ArrayList<HgItem> arrayList;
    LayoutInflater inflater;

    public HgAdapter(Context context,ArrayList<HgItem> arrayList){
        this.context=context;
        this.arrayList=arrayList;
        inflater= LayoutInflater.from(context);

    }



    @Override
    public int getCount() {
        return arrayList.size();
    }

    @Override
    public Object getItem(int i) {
        return arrayList.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        Holder holder=null;
        if (null==view){
            holder=new Holder();
            view=inflater.inflate(R.layout.hgl_layout,null,false);
            holder.hgda=view.findViewById(R.id.hgda);
            holder.hgorder=view.findViewById(R.id.hgorder);
            holder.hgprice=view.findViewById(R.id.hgprice);
            holder.hgscale=view.findViewById(R.id.hgscale);
            view.setTag(holder);
          }else {
            holder= (Holder) view.getTag();
           }
          holder.hgda.setText(arrayList.get(i).getPr());
          holder.hgorder.setText(arrayList.get(i).getGoodsName());
          holder.hgprice.setText("¥"+arrayList.get(i).getSellCount());
          holder.hgscale.setText("--");
         return view;
        }



  public class Holder{
        TextView hgda,hgorder,hgprice,hgscale;

     }

}
